package com.eascs.admin.o2o.creditarchive.service;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import com.eascs.admin.o2o.creditarchive.dao.CreditArchiveBaseDao;
import com.eascs.admin.o2o.creditarchive.form.O2oCreditArchiveVo;
import com.eascs.archive.entity.CreditArchiveRecordEntity;

@Service
public class CreditArchiveService {
	
	@Inject
	CreditArchiveBaseDao creditArchiveDao;
	
	
	
	public CreditArchiveRecordEntity getCreditArchiveRecordById(String id) {
		
		return creditArchiveDao.getCreditArchiveRecordById(id);
	}
	
    public boolean updateCreditArchiveRecordEntity(CreditArchiveRecordEntity creditArchiveRecordEntity) {
		
		return creditArchiveDao.updateById(creditArchiveRecordEntity)>0?true:false;
	}
	public boolean  updateCreditArchive(O2oCreditArchiveVo o2oCreditArchiveVo){
		
		if(o2oCreditArchiveVo!=null){
			if(("plat").equals(o2oCreditArchiveVo.getType())){
				Object[] o={o2oCreditArchiveVo.getAuthBookCount(),o2oCreditArchiveVo.getIdCardCopies(),o2oCreditArchiveVo.getExpressSendCertPlatform(),o2oCreditArchiveVo.getExpressCompanyPlatform(),o2oCreditArchiveVo.getExpressNoPlatform(),o2oCreditArchiveVo.getReceiverPlatform(),o2oCreditArchiveVo.getRemarkPlatform(),o2oCreditArchiveVo.getReferId()};
				String sql ="update o2o_credit_archive_record set  auth_book_count = ?,id_card_copies = ?,express_send_cert_platform = ?,express_company_platform = ?,express_no_platform = ?,receiver_platform = ?,remark_platform = ?  where id = ? ";
				return creditArchiveDao.updateCreditArchive(sql,o);
			}else{
				Object[] o={o2oCreditArchiveVo.getAuthBookCount(),o2oCreditArchiveVo.getIdCardCopies(),o2oCreditArchiveVo.getExpressSendCertProvince(),o2oCreditArchiveVo.getExpressCompanyProvince(),o2oCreditArchiveVo.getExpressNoProvince(),o2oCreditArchiveVo.getReceiverProvince(),o2oCreditArchiveVo.getRemarkProvince(),o2oCreditArchiveVo.getReferId()};
				String sql="update o2o_credit_archive_record set   auth_book_count = ?,id_card_copies = ?,express_send_cert_province = ?,express_company_province = ?,express_no_province = ?,receiver_province = ?,remark_province = ?  where id = ?";
				return creditArchiveDao.updateCreditArchive(sql,o);
			}
		}else{
			return false;
		}
	}

}
